[IA64] Fix xen/ia64 save/restore error recovery path.
authorAlex Williamson <alex.williamson@hp.com>
Mon, 21 May 2007 03:28:48 +0000 (21:28 -0600)
committerAlex Williamson <alex.williamson@hp.com>
Mon, 21 May 2007 03:28:48 +0000 (21:28 -0600)
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
tools/libxc/ia64/xc_ia64_linux_restore.c
tools/libxc/ia64/xc_ia64_linux_save.c

index 44d500cd897abfb00cde18583053976b008c7b74..21d0e09f1eca0f3aa8f320d57ebc2a046ef092a7 100644 (file)
@@ -48,10 +48,11 @@ read_page(int xc_handle, int io_fd, uint32_t dom, unsigned long pfn)
                                PROT_READ|PROT_WRITE, pfn);
     if (mem == NULL) {
             ERROR("cannot map page");
-           return -1;
+            return -1;
     }
     if (!read_exact(io_fd, mem, PAGE_SIZE)) {
             ERROR("Error when reading from state file (5)");
+            munmap(mem, PAGE_SIZE);
             return -1;
     }
     munmap(mem, PAGE_SIZE);
@@ -270,6 +271,7 @@ xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
     }
     if (!read_exact(io_fd, shared_info, PAGE_SIZE)) {
             ERROR("Error when reading shared_info page");
+            munmap(shared_info, PAGE_SIZE);
            goto out;
     }
 
@@ -286,6 +288,10 @@ xc_domain_restore(int xc_handle, int io_fd, uint32_t dom,
     /* Uncanonicalise the suspend-record frame number and poke resume rec. */
     start_info = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
                                       PROT_READ | PROT_WRITE, gmfn);
+    if (start_info == NULL) {
+        ERROR("cannot map start_info page");
+        goto out;
+    }
     start_info->nr_pages = p2m_size;
     start_info->shared_info = shared_info_frame << PAGE_SHIFT;
     start_info->flags = 0;
index 8fcd9d0a9db6cc4404e38ccf50b3092e295e6af8..ceb91795c42b91b9f6f2726e479b14fcf0c3b2cf 100644 (file)
@@ -361,11 +361,13 @@ xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
 
             if (!write_exact(io_fd, &N, sizeof(N))) {
                 ERROR("write: max_pfn");
+                munmap(mem, PAGE_SIZE);
                 goto out;
             }
 
             if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) {
                 ERROR("Error when writing to state file (5)");
+                munmap(mem, PAGE_SIZE);
                 goto out;
             }
             munmap(mem, PAGE_SIZE);
@@ -470,6 +472,7 @@ xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
     }
     if (write(io_fd, mem, PAGE_SIZE) != PAGE_SIZE) {
         ERROR("Error when writing privreg to state file (5)");
+        munmap(mem, PAGE_SIZE);
         goto out;
     }
     munmap(mem, PAGE_SIZE);